home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: analyzeFileAddSlotted.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:33 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "volume.h"
- #include "openlog.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "logaction.h"
- #include "log.h"
- #include "log_extfuncs.h"
- #include "recover_intfuncs.h"
- #include "trans_extfuncs.h"
- #include "analyze_extfuncs.h"
- #include "thread_globals.h"
-
- /*
- * This function analyzes both LOG_ACTION_FILE_ADD_SLOTTED and
- * LOG_ACTION_FILE_REMOVE_SLOTTED log records.
- */
-
- void
- analyzeFileAddSlotted (
-
- LOGRECORDHDR *record
- )
- {
-
- PID lastPID;
- PID *rootPID;
- DIRTYPAGEINFO *dirtyInfo;
- BOOL *firstPage;
-
- TRACE(TR_IO, TR_LEVEL_1);
-
-
- /*
- * Get a pointer to the file root page id
- */
- rootPID = &record->actionPid;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("file root page:%d", rootPID->page));
-
- /*
- * check to see if the page is in the dirty list
- */
- if ((dirtyInfo = searchDirtyPageTable(rootPID)) == NULL) {
-
- /*
- * create a new entry
- */
- if ((dirtyInfo = insertDirtyPageTable(rootPID)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * update the dirty page information.
- */
- dirtyInfo->lsn = record->recordLSN;
- dirtyInfo->lrc = record->actionLRC;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("lsn:%d,lrc:%d", dirtyInfo->lsn.offset, dirtyInfo->lrc.count));
-
- }
-
- /*
- * If the page is not the first one, then add the last page
- * in the file to the dirty page table
- */
- firstPage = (BOOL*) GET_LOG_IMAGE(record, 0);
- if ( !(*firstPage)) {
-
- /*
- * Determine the image containing the id of the last
- * slotted page in the file
- * Get a pointer to the last slotted page in the file
- */
- if (record->action == LOG_ACTION_FILE_ADD_SLOTTED) {
- /* page is second one in this image */
- lastPID.page = *(((SHORTPID*) GET_LOG_IMAGE(record, 1))+1);
- } else {
- SM_ASSERT(LEVEL_3, record->action == LOG_ACTION_FILE_REMOVE_SLOTTED);
- /* page is only one in this image */
- lastPID.page = *(SHORTPID*) GET_LOG_IMAGE(record, 1);
- }
- lastPID.volid = rootPID->volid;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("last slotted page:%d", lastPID.page));
-
- /*
- * check to see if the page is in the dirty list
- */
- if ((dirtyInfo = searchDirtyPageTable(&lastPID)) == NULL) {
-
- /*
- * create a new entry
- */
- if ((dirtyInfo = insertDirtyPageTable(&lastPID)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * update the dirty page information.
- * NOTE: this code must match that in
- * analyzeCommonClientRecord()!!
- */
- dirtyInfo->lsn = record->recordLSN;
- dirtyInfo->lrc.count = 1;
- dirtyInfo->lrc.wrapCount = 0;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("lsn:%d,lrc:%d", dirtyInfo->lsn.offset, dirtyInfo->lrc.count));
-
- /*
- * Remember the transaction which added this page. Later, if
- * it is one that was aborted, the page's firstLSN will be
- * changed to the transaction's firstLSN.
- */
- dirtyInfo->tid = record->tid;
- dirtyInfo->flags |= DPT_FIXFIRSTLRC;
-
- }
- }
- }
-